#include<bits/stdc++.h>
using namespace std;
int main(){
	char ch;
	double a;
	cin>>ch>>a;
	if(a <= 3)
		cout<<"fare=10.0";
	else if(ch == 'A')
		cout<<"fare="<<fixed<<setprecision(1)<<10+(a-3)*3;
	else if(ch == 'B')
		cout<<"fare="<<fixed<<setprecision(1)<<10+(a-3)*2;
	else
		cout<<"fare="<<fixed<<setprecision(1)<<10+(a-3)*1.5;
	return 0;
}
